package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.OtherRoomEventConfig;
import com.ruoyi.system.domain.OtherRoundConfig;
import com.ruoyi.system.mapper.OtherRoomEventConfigMapper;
import com.ruoyi.system.mapper.OtherRoundConfigMapper;
import com.ruoyi.system.service.IOtherRoomEventConfigService;
import com.ruoyi.system.service.IOtherRoundConfigService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@DataSource(value = DataSourceType.SLAVE)
public class OtherRoomEventConfigServiceImpl extends ServiceImpl<OtherRoomEventConfigMapper, OtherRoomEventConfig> implements IOtherRoomEventConfigService {

    @Resource
    private OtherRoomEventConfigMapper otherRoomEventConfigMapper;

    @DataSource(value = DataSourceType.SLAVE)
    public OtherRoomEventConfig getRoomEventConfigByRoomId(String roomId) {
        return otherRoomEventConfigMapper.selectOne(new LambdaQueryWrapper<OtherRoomEventConfig>().eq(OtherRoomEventConfig::getRoomID, roomId));
    }


    @DataSource(value = DataSourceType.SLAVE)
    public int updateRoomEventConfigByRoomId(OtherRoomEventConfig otherRoomEventConfig) {
        return otherRoomEventConfigMapper.updateById(otherRoomEventConfig);
    }
}
